package com.example.user.controller;

import com.example.api.user.User;
import com.example.api.user.UserServiceApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.UUID;

/**
 * @author 86188
 */
@RestController
@RefreshScope
public class UserController implements UserServiceApi {

    @Override
    public User createUserByPhone(String phone) {
        User user = new User();
        user.setId(UUID.randomUUID().toString().replace("-",""));
        user.setCreated(LocalDateTime.now());
        user.setUsername("泰斯特");
        user.setPassword(Long.toHexString(System.currentTimeMillis()));
        user.setPhone(phone);
        user.setToken("");
        user.setTokenExpire(LocalDateTime.now().plusSeconds(30));
        return user;
    }

    @Value("${book.name}")
    private String bookName = "pang";
@RequestMapping("/ping")
public String ping() {
        return bookName;
        }
        }
